#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int minSubArrayLen(int target, vector<int> &nums)
{
    auto p = nums.begin(), q = p;
    int minLen = INT_MAX, sum = 0, len = 0;
    while (q != nums.end())
    {
        sum += *(q++);
        len++;
        while (sum - *p >= target)
        {
            sum -= *(p++);
            len--;
        }
        if (sum >= target)
        {
            minLen = minLen >= len ? len : minLen;
        }
    }
    return minLen == INT_MAX ? 0 : minLen;
}

int main()
{
    int target = 7;
    vector<int> nums = {2, 3, 1, 2, 4, 3};
    cout << minSubArrayLen(target, nums) << endl;
    return 0;
}
